package com.flipdf2.serialize.ppml.element;

import java.util.ArrayList;
import java.util.List;

import org.jdom.Element;
import org.jdom.Namespace;

import com.flipdf2.serialize.ppml.PPMLException;

public class PPMLTicketState {
	public static final String NAME = "TICKET_STATE";
	
	private List<PPMLTicketRef> ticketRefList;
	
	public Element toXML(Namespace defaultNamespace) {
		Element root = null;
		if (defaultNamespace != null) {
			root = new Element(NAME, defaultNamespace);
		} else {
			root = new Element(NAME);	
		}
		
		if (ticketRefList != null && ticketRefList.size() > 0) {
			for (int i = 0, n = ticketRefList.size(); i < n; i++) {
				root.addContent(ticketRefList.get(i).toXML(defaultNamespace));
			}
		}
		
		return root;
	}

	public void check() throws PPMLException {
	}
	
	public List<PPMLTicketRef> getTicketRefList() {
		return ticketRefList;
	}

	public void setTicketRefList(List<PPMLTicketRef> ticketRefList) {
		this.ticketRefList = ticketRefList;
	}
	
	public void addTicketRef(PPMLTicketRef ticketRef) {
		if (this.ticketRefList == null)
			this.ticketRefList = new ArrayList<PPMLTicketRef>();
		this.ticketRefList.add(ticketRef);
	}
}
